<script>

/**
 * Orders Component
 */
export default {
  data() {
    return {
      ordersData: [
        {
          serialNum: "1",
          sharesName: "骏成科技",
          code: "301106",
          enterpriseName: "江苏骏成电子科技股份有限公司",
          exchangeName: "深圳证券交易所",
          listingDate: "2022-01-28",
          industry: "汽车制造业",
          region: "浙江省",
          establishDate: "1997-08-12",
          updateDate: "16分钟前",
        }
      ],
      totalRows: 100,
      currentPage: 1,
      perPage: 10,
      fields: [
        { key: "serialNum", label: "序号" },
        { key: "sharesName", label: "股票名称" },
        { key: "code", label: "股票代码" },
        { key: "enterpriseName", label: "企业名称" },
        { key: "exchangeName", label: "交易所名称" },
        { key: "listingDate", label: "上市日期" },
        { key: "industry", label: "所属行业" },
        { key: "region", label: "所属地区" },
        { key: "establishDate", label: "成立日期" },
        { key: "updateDate", label: "更新日期" },
      ],
    };
  },
  watch: {
    "currentPage": {
      handler(){
        console.log("触发更新");
      }
    }
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.ordersData.length;
  },
  methods: {
    /**
     * Search the table data with search input
     */
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
  }
};
</script>

<template>
  <div>
    <!-- 搜索 -->
      <div class="search-box">
        <div class="position-relative search">
          <input type="text" class="form-control" placeholder="请输入股票代码或股票简称" />
          <i class="mdi mdi-magnify search-icon"></i>
        </div>
      </div>
      <div class="allNum">
        <div class="searchNum">为您检索到<span>5,000+</span>条股票信息</div>
        <div>
          <b-dropdown dropup variant="secondary" class="butn">
            <template slot="button-content">
              <i class="ri-add-line align-middle" style="font-size: 1rem;"></i>
              <span style="margin:0 20px 0 6px;">更多操作</span>
              <i class="mdi mdi-chevron-up"></i>
            </template>
            <b-dropdown-item-button>创建接口</b-dropdown-item-button>
            <b-dropdown-item-button>查看日志</b-dropdown-item-button>
            <b-dropdown-item-button>标准模式</b-dropdown-item-button>
            <b-dropdown-item-button>SQL模式</b-dropdown-item-button>
            <b-dropdown-item-button>数据字段</b-dropdown-item-button>
          </b-dropdown>
        </div>
      </div>
      <div class="table-responsive">
        <b-table
          class="table-centered"
          :items="ordersData"
          :fields="fields"
          responsive="sm"
          :per-page="perPage"
          :current-page="1"
          thead-class="thead-light"
          @filtered="onFiltered"
        >
          <template v-slot:cell(sharesName)="row">
            <a style="font-size:.9rem;" href="/#/datahouse/securitieslistCompanyDetail">{{row.value}}</a>
          </template>
        </b-table>
      </div>
      <div class="row">
        <div class="col">
          <div class="dataTables_paginate paging_simple_numbers float-right">
            <ul class="pagination pagination-rounded mb-0">
              <!-- pagination -->
              <b-pagination v-model="currentPage" :total-rows="totalRows" :per-page="perPage"></b-pagination>
            </ul>
          </div>
        </div>
      </div>
  </div>
</template>
<style lang="scss" scoped>
.search {
  max-width: 300px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.border-radius{
  border-radius: 0px;
  border-bottom-left-radius: 30px;
  border-top-left-radius: 30px;
}
.right-dropdown{
  ::v-deep .btn{
    font-size: 0;
    border-radius: 0px;
    padding: 0.47rem 0.5rem;
    border-bottom-right-radius: 30px;
    border-top-right-radius: 30px;
    i{
      font-size: 0.9rem;
      vertical-align: middle;
    }
  }
}
.table-centered{
  ::v-deep thead,::v-deep tbody{
    tr{
      th:last-child,td:last-child{
        text-align: right;
      }
    }
  }
  ::v-deep tbody{
    tr{
      td{
        font-size: 13px;
      }
    }
  }
}
.allNum{
  padding-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.searchNum{
  span{
    font-size: 1rem;
    color: #3444c1;
    margin: 0 4px;
    font-weight: 600;
  }
}
.butn{
  ::v-deep .btn{
    background-color: #252b3b;
    border-color: #252b3b;
    border-radius: 30px;
    display: flex;
    align-items: center;
  }
  ::v-deep .btn-secondary.focus {
    box-shadow: 0 0 0 0.15rem rgb(37 40 58 / 50%);
  }
}
</style>

